﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel.Composition;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(IBrand))]
    public partial class Brand:Entity, IBrand
    {
      
        IQueryable<IProduct> IBrand.Products
        {
            get 
            {
                return this.DataContext.Products.Where(i => i.BrandId == this.Id);
            }
        }

     

        IQueryable<IProductType> _ProductTypes;
        public IQueryable<IProductType> ProductTypes
        {
            get
            {
                if (this._ProductTypes == null)
                {
                    this._ProductTypes = this.DataContext.BrandProductTypes
                        .Where(i => i.BrandId == this.Id)
                        .Select(i => i.ProductType as IProductType);
                }

                return this._ProductTypes;
            }
            set
            {
                this._ProductTypes = value;
            }
        }
    }
}
